Skip to content

BUG: Error while saving DataFrame with TimedeltaIndex to .csv #10833 #10845

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Aug 21, 2015
Merged

BUG: Error while saving DataFrame with TimedeltaIndex to .csv #10833 #10845

merged 4 commits into from
Aug 21, 2015

Conversation

soupault
Copy link
Contributor

Fix in accordance with #10833

@jreback
Copy link
Contributor

jreback commented Aug 18, 2015

needs some tests. use the example you gave. add into test_frame.py. needs a round-trip tests. Note that you will have to read it as object dtype and the run it thru to_timedelta to compare against the original.

pls also add a whatsnew note.

@jreback jreback added Bug IO CSV read_csv, to_csv Timedelta Timedelta data type labels Aug 18, 2015
@jreback jreback modified the milestones: 0.17.0, Next Major Release Aug 18, 2015
@soupault
Copy link
Contributor Author

It would be nice to refactor test_frame.py code... Btw, there are two existing assert methods: self.assertXXX and assert_frame_equal. I've used the first one as it seems like the second is to be reworked.

df_test.index = pd.to_timedelta(df_test.index)
df_test.index.rename('timestamp', inplace=True)

self.assertTrue(df_test.equal(df_orig))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you could do this, but it is not nearly as imformative as assert_frame_equal. pls change.

@jreback jreback modified the milestones: 0.17.0, Next Major Release Aug 20, 2015
@jreback
Copy link
Contributor

jreback commented Aug 20, 2015

@soupault yes of course test_frame could use a refactor. but that's another PR!

result = pd.read_csv(path, index_col='dt_index')
result.index = pd.to_timedelta(result.index)
result['dt_data'] = pd.to_timedelta(result['dt_data'])

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

set the index name for now so this issue is independent


result = pd.read_csv(path, index_col='dt_index')
result.index = pd.to_timedelta(result.index)
# TODO: remove renaming when GH 10875 is solved
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fine, though result.index.name = 'dt_index' as well

jreback added a commit that referenced this pull request Aug 21, 2015
BUG: Error while saving DataFrame with TimedeltaIndex to .csv #10833
@jreback jreback merged commit 2c5b458 into pandas-dev:master Aug 21, 2015
@jreback
Copy link
Contributor

jreback commented Aug 21, 2015

thank you sir!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug IO CSV read_csv, to_csv Timedelta Timedelta data type
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants